import time

from resource.path_info import *

"""
立即直播
"""
def check_living_status(self, d):
    if d.xpath(to_enter_living_xpath).exists:
        d.xpath(to_enter_living_xpath).click()
        d.xpath(ensure_start_video_btn_xpath).wait(timeout=5.0)
        d.xpath(ensure_start_video_btn_xpath).click()
        d.xpath(end_live_broadcast_btn_xpath).wait(timeout=10.0)
        assert True == d.xpath(end_live_broadcast_btn_xpath).exists
        end_living_broadcast(self, d)

"""
结束直播
"""

def end_living_broadcast(self, d):
    print("end_broadcast")
    d.xpath(end_live_broadcast_btn_xpath).click()
    d.xpath(ensure_alert_xpath).click()
    d.xpath(end_broadcast_title_xpath).wait(timeout=3.0)
    assert True == d.xpath(end_broadcast_title_xpath).exists
    d.xpath(end_broadcast_back_xpath).click()
    time.sleep(2)
    return self
